//
//  UIView+MASShorthandAdditions.h
//  Masonry
//
//  Created by Jonas Budelmann on 22/07/13.
//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
//

#import "View+MASAdditions_yjw.h"

#ifdef MAS_SHORTHAND

/**
 *	Shorthand view additions without the 'mas_' prefixes,
 *  only enabled if MAS_SHORTHAND is defined
 */
@interface MAS_YJW_VIEW (MASShorthandAdditions_yjw)

@property (nonatomic, strong, readonly) MASViewAttribute_yjw *left;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *top;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *right;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *bottom;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *leading;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *trailing;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *width;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *height;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *centerX;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *centerY;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *baseline;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *(^attribute)(NSLayoutAttribute attr);

@property (nonatomic, strong, readonly) MASViewAttribute_yjw *firstBaseline;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *lastBaseline;

#if TARGET_OS_IPHONE || TARGET_OS_TV

@property (nonatomic, strong, readonly) MASViewAttribute_yjw *leftMargin;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *rightMargin;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *topMargin;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *bottomMargin;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *leadingMargin;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *trailingMargin;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *centerXWithinMargins;
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *centerYWithinMargins;

#endif

#if TARGET_OS_IPHONE || TARGET_OS_TV

@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideLeading NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideTrailing NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideLeft NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideRight NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideTop NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideBottom NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideWidth NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideHeight NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideCenterX NS_AVAILABLE_IOS(11.0);
@property (nonatomic, strong, readonly) MASViewAttribute_yjw *safeAreaLayoutGuideCenterY NS_AVAILABLE_IOS(11.0);

#endif

- (NSArray *)makeConstraints:(void(^)(MASConstraintMaker_yjw *make))block;
- (NSArray *)updateConstraints:(void(^)(MASConstraintMaker_yjw *make))block;
- (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker_yjw *make))block;

@end

#define MAS_ATTR_FORWARD_YJW(attr)  \
- (MASViewAttribute_yjw *)attr {    \
    return [self mas_##attr];   \
}

#define MAS_ATTR_FORWARD_YJW_AVAILABLE(attr, available)  \
- (MASViewAttribute_yjw *)attr available {    \
    return [self mas_##attr];   \
}

@implementation MAS_YJW_VIEW (MASShorthandAdditions)

MAS_ATTR_FORWARD_YJW(top);
MAS_ATTR_FORWARD_YJW(left);
MAS_ATTR_FORWARD_YJW(bottom);
MAS_ATTR_FORWARD_YJW(right);
MAS_ATTR_FORWARD_YJW(leading);
MAS_ATTR_FORWARD_YJW(trailing);
MAS_ATTR_FORWARD_YJW(width);
MAS_ATTR_FORWARD_YJW(height);
MAS_ATTR_FORWARD_YJW(centerX);
MAS_ATTR_FORWARD_YJW(centerY);
MAS_ATTR_FORWARD_YJW(baseline);

MAS_ATTR_FORWARD_YJW(firstBaseline);
MAS_ATTR_FORWARD_YJW(lastBaseline);

#if TARGET_OS_IPHONE || TARGET_OS_TV

MAS_ATTR_FORWARD_YJW(leftMargin);
MAS_ATTR_FORWARD_YJW(rightMargin);
MAS_ATTR_FORWARD_YJW(topMargin);
MAS_ATTR_FORWARD_YJW(bottomMargin);
MAS_ATTR_FORWARD_YJW(leadingMargin);
MAS_ATTR_FORWARD_YJW(trailingMargin);
MAS_ATTR_FORWARD_YJW(centerXWithinMargins);
MAS_ATTR_FORWARD_YJW(centerYWithinMargins);

MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideLeading, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideTrailing, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideLeft, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideRight, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideTop, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideBottom, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideWidth, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideHeight, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideCenterX, NS_AVAILABLE_IOS(11.0));
MAS_ATTR_FORWARD_YJW_AVAILABLE(safeAreaLayoutGuideCenterY, NS_AVAILABLE_IOS(11.0));

#endif

- (MASViewAttribute_yjw *(^)(NSLayoutAttribute))attribute {
    return [self mas_attribute];
}

- (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker_yjw *))block {
    return [self mas_makeConstraints:block];
}

- (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker_yjw *))block {
    return [self mas_updateConstraints:block];
}

- (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker_yjw *))block {
    return [self mas_remakeConstraints:block];
}

@end

#endif
